using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace Microsoft.SqlServer.Management.SqlManagerUI
{
	public class RemoteCreditDialog : Form
	{
		private ProviderEntity _provider;

		private DatabaseEntity _database;

		private IContainer components;

		private Label lblWebServiceAddress;

		private Label lblProviderName;

		private Label lblPassword;

		private Label lblUsername;

		private TextBox txtProviderPassword;

		private TextBox txtProviderUsername;

		private GroupBox grpProvider;

		private GroupBox grpDatabase;

		private Label lblServerName;

		private Label lblDatabaseName;

		private Label lblProviderNameText;

		private Label lblWebServiceText;

		private TextBox txtDbPassword;

		private Label lblDbPassword;

		private TextBox txtDbUser;

		private Label lblDbUsername;

		private Label lblDbNameText;

		private Label lblServerNameText;

		private Panel pnlFooterButtons;

		private Button btnOk;

		private Button btnCancel;

		private Label lblEnterUserAndPassword;

		public ProviderEntity Provider
		{
			get
			{
				return this._provider;
			}
			set
			{
				if (value != null)
				{
					this._provider = value;
					this.lblProviderNameText.Text = this._provider.Name;
					this.lblWebServiceText.Text = this._provider.WebServiceAddress;
					this.txtProviderUsername.Text = this._provider.UserName;
					this.txtProviderPassword.Text = this._provider.Password;
					return;
				}
				this.lblProviderNameText.Text = string.Empty;
				this.lblWebServiceText.Text = string.Empty;
				this.txtProviderUsername.Text = string.Empty;
				this.txtProviderPassword.Text = string.Empty;
				this.grpProvider.Enabled = false;
			}
		}

		public DatabaseEntity Database
		{
			get
			{
				return this._database;
			}
			set
			{
				if (value != null)
				{
					this._database = value;
					this.lblDbNameText.Text = this._database.DatabaseName;
					this.lblServerNameText.Text = this._database.ServerName;
					this.txtDbUser.Text = this._database.UserName;
					this.txtDbPassword.Text = this._database.Password;
					return;
				}
				this.lblDbNameText.Text = string.Empty;
				this.lblServerNameText.Text = string.Empty;
				this.txtDbUser.Text = string.Empty;
				this.txtDbPassword.Text = string.Empty;
				this.grpDatabase.Enabled = false;
			}
		}

		public RemoteCreditDialog()
		{
			this.InitializeComponent();
			base.Icon = CUtils.LoadIcon("server.ico");
			this.LoadStrings();
		}

		private void LoadStrings()
		{
			this.btnOk.Text = GenScriptWizSR.OK;
			this.btnCancel.Text = GenScriptWizSR.CancelBtn;
			this.Text = GenScriptWizSR.RemoteCreditDialogTitle;
			this.lblEnterUserAndPassword.Text = GenScriptWizSR.RemoteCreditSubTitle;
			this.lblProviderName.Text = GenScriptWizSR.RemoteCreditProviderName;
			this.lblServerName.Text = GenScriptWizSR.RemoteCreditServerName;
			this.lblWebServiceAddress.Text = GenScriptWizSR.RemoteCreditWebAdd;
			this.lblUsername.Text = GenScriptWizSR.RemoteCreditWebSerUser;
			this.lblPassword.Text = GenScriptWizSR.RemoteCreditWebSerPassword;
			this.lblDbUsername.Text = GenScriptWizSR.RemoteCreditUserName;
			this.lblDbPassword.Text = GenScriptWizSR.RemoteCreditPassword;
			this.lblDatabaseName.Text = GenScriptWizSR.RemoteCreditDatabaseName;
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			if (this._provider != null)
			{
				this._provider.UserName = this.txtProviderUsername.Text;
				this._provider.Password = this.txtProviderPassword.Text;
			}
			if (this._database != null)
			{
				this._database.UserName = this.txtDbUser.Text;
				this._database.Password = this.txtDbPassword.Text;
			}
			base.Close();
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}

		private void InitializeComponent()
		{
			this.lblWebServiceAddress = new Label();
			this.lblProviderName = new Label();
			this.lblPassword = new Label();
			this.lblUsername = new Label();
			this.txtProviderPassword = new TextBox();
			this.txtProviderUsername = new TextBox();
			this.grpProvider = new GroupBox();
			this.lblProviderNameText = new Label();
			this.lblWebServiceText = new Label();
			this.grpDatabase = new GroupBox();
			this.txtDbPassword = new TextBox();
			this.lblDbPassword = new Label();
			this.lblServerNameText = new Label();
			this.lblDbNameText = new Label();
			this.txtDbUser = new TextBox();
			this.lblDbUsername = new Label();
			this.lblServerName = new Label();
			this.lblDatabaseName = new Label();
			this.pnlFooterButtons = new Panel();
			this.btnOk = new Button();
			this.btnCancel = new Button();
			this.lblEnterUserAndPassword = new Label();
			this.grpProvider.SuspendLayout();
			this.grpDatabase.SuspendLayout();
			this.pnlFooterButtons.SuspendLayout();
			base.SuspendLayout();
			this.lblWebServiceAddress.AutoSize = true;
			this.lblWebServiceAddress.Location = new Point(10, 39);
			this.lblWebServiceAddress.Name = "lblWebServiceAddress";
			this.lblWebServiceAddress.Size = new Size(107, 13);
			this.lblWebServiceAddress.TabIndex = 2;
			this.lblWebServiceAddress.Text = "A:Web service address";
			this.lblProviderName.AutoSize = true;
			this.lblProviderName.Location = new Point(10, 17);
			this.lblProviderName.Name = "lblProviderName";
			this.lblProviderName.Size = new Size(35, 13);
			this.lblProviderName.TabIndex = 3;
			this.lblProviderName.Text = "A:Name";
			this.lblPassword.AutoSize = true;
			this.lblPassword.Location = new Point(10, 87);
			this.lblPassword.Name = "lblPassword";
			this.lblPassword.Size = new Size(53, 13);
			this.lblPassword.TabIndex = 5;
			this.lblPassword.Text = "A:Password";
			this.lblUsername.AutoSize = true;
			this.lblUsername.Location = new Point(10, 63);
			this.lblUsername.Name = "lblUsername";
			this.lblUsername.Size = new Size(58, 13);
			this.lblUsername.TabIndex = 4;
			this.lblUsername.Text = "A:User name";
			this.txtProviderPassword.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.txtProviderPassword.Location = new Point(166, 89);
			this.txtProviderPassword.Name = "txtProviderPassword";
			this.txtProviderPassword.PasswordChar = '*';
			this.txtProviderPassword.Size = new Size(245, 20);
			this.txtProviderPassword.TabIndex = 1;
			this.txtProviderUsername.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.txtProviderUsername.Location = new Point(166, 63);
			this.txtProviderUsername.Name = "txtProviderUsername";
			this.txtProviderUsername.Size = new Size(245, 20);
			this.txtProviderUsername.TabIndex = 0;
			this.grpProvider.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.grpProvider.Controls.Add(this.lblUsername);
			this.grpProvider.Controls.Add(this.lblPassword);
			this.grpProvider.Controls.Add(this.lblProviderNameText);
			this.grpProvider.Controls.Add(this.lblProviderName);
			this.grpProvider.Controls.Add(this.lblWebServiceText);
			this.grpProvider.Controls.Add(this.lblWebServiceAddress);
			this.grpProvider.Controls.Add(this.txtProviderPassword);
			this.grpProvider.Controls.Add(this.txtProviderUsername);
			this.grpProvider.Location = new Point(6, 24);
			this.grpProvider.Name = "grpProvider";
			this.grpProvider.Size = new Size(431, 117);
			this.grpProvider.TabIndex = 0;
			this.grpProvider.TabStop = false;
			this.lblProviderNameText.AutoSize = true;
			this.lblProviderNameText.Location = new Point(163, 17);
			this.lblProviderNameText.MinimumSize = new Size(35, 13);
			this.lblProviderNameText.Name = "lblProviderNameText";
			this.lblProviderNameText.Size = new Size(35, 13);
			this.lblProviderNameText.TabIndex = 3;
			this.lblProviderNameText.Text = "A:Name";
			this.lblWebServiceText.AutoSize = true;
			this.lblWebServiceText.Location = new Point(163, 39);
			this.lblWebServiceText.Name = "lblWebServiceText";
			this.lblWebServiceText.Size = new Size(67, 13);
			this.lblWebServiceText.TabIndex = 2;
			this.lblWebServiceText.Text = "A:Server name";
			this.grpDatabase.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.grpDatabase.Controls.Add(this.txtDbPassword);
			this.grpDatabase.Controls.Add(this.lblDbPassword);
			this.grpDatabase.Controls.Add(this.lblServerNameText);
			this.grpDatabase.Controls.Add(this.lblDbNameText);
			this.grpDatabase.Controls.Add(this.txtDbUser);
			this.grpDatabase.Controls.Add(this.lblDbUsername);
			this.grpDatabase.Controls.Add(this.lblServerName);
			this.grpDatabase.Controls.Add(this.lblDatabaseName);
			this.grpDatabase.Location = new Point(6, 142);
			this.grpDatabase.Name = "grpDatabase";
			this.grpDatabase.Size = new Size(431, 120);
			this.grpDatabase.TabIndex = 1;
			this.grpDatabase.TabStop = false;
			this.txtDbPassword.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.txtDbPassword.Location = new Point(166, 91);
			this.txtDbPassword.Name = "txtDbPassword";
			this.txtDbPassword.PasswordChar = '*';
			this.txtDbPassword.Size = new Size(245, 20);
			this.txtDbPassword.TabIndex = 3;
			this.lblDbPassword.AutoSize = true;
			this.lblDbPassword.Location = new Point(10, 91);
			this.lblDbPassword.Name = "lblDbPassword";
			this.lblDbPassword.Size = new Size(53, 13);
			this.lblDbPassword.TabIndex = 8;
			this.lblDbPassword.Text = "A:Password";
			this.lblServerNameText.AutoSize = true;
			this.lblServerNameText.Location = new Point(163, 41);
			this.lblServerNameText.Name = "lblServerNameText";
			this.lblServerNameText.Size = new Size(67, 13);
			this.lblServerNameText.TabIndex = 3;
			this.lblServerNameText.Text = "A:Server name";
			this.lblDbNameText.AutoSize = true;
			this.lblDbNameText.Location = new Point(163, 16);
			this.lblDbNameText.Name = "lblDbNameText";
			this.lblDbNameText.Size = new Size(67, 13);
			this.lblDbNameText.TabIndex = 3;
			this.lblDbNameText.Text = "A:Server name";
			this.txtDbUser.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.txtDbUser.Location = new Point(166, 65);
			this.txtDbUser.Name = "txtDbUser";
			this.txtDbUser.Size = new Size(245, 20);
			this.txtDbUser.TabIndex = 2;
			this.lblDbUsername.AutoSize = true;
			this.lblDbUsername.Location = new Point(10, 65);
			this.lblDbUsername.Name = "lblDbUsername";
			this.lblDbUsername.Size = new Size(67, 13);
			this.lblDbUsername.TabIndex = 7;
			this.lblDbUsername.Text = "A:Server name";
			this.lblServerName.AutoSize = true;
			this.lblServerName.Location = new Point(10, 40);
			this.lblServerName.Name = "lblServerName";
			this.lblServerName.Size = new Size(67, 13);
			this.lblServerName.TabIndex = 2;
			this.lblServerName.Text = "A:Server name";
			this.lblDatabaseName.AutoSize = true;
			this.lblDatabaseName.Location = new Point(10, 16);
			this.lblDatabaseName.Name = "lblDatabaseName";
			this.lblDatabaseName.Size = new Size(82, 13);
			this.lblDatabaseName.TabIndex = 1;
			this.lblDatabaseName.Text = "A:Database name";
			this.pnlFooterButtons.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.pnlFooterButtons.Controls.Add(this.btnOk);
			this.pnlFooterButtons.Controls.Add(this.btnCancel);
			this.pnlFooterButtons.Location = new Point(2, 263);
			this.pnlFooterButtons.Name = "pnlFooterButtons";
			this.pnlFooterButtons.Size = new Size(444, 29);
			this.pnlFooterButtons.TabIndex = 10;
			this.btnOk.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.btnOk.DialogResult = DialogResult.OK;
			this.btnOk.Location = new Point(281, 3);
			this.btnOk.Name = "btnOk";
			this.btnOk.Size = new Size(75, 23);
			this.btnOk.TabIndex = 4;
			this.btnOk.Text = "A:OK";
			this.btnOk.UseVisualStyleBackColor = true;
			this.btnOk.Click += new EventHandler(this.btnOk_Click);
			this.btnCancel.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.btnCancel.DialogResult = DialogResult.Cancel;
			this.btnCancel.Location = new Point(362, 3);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new Size(75, 23);
			this.btnCancel.TabIndex = 5;
			this.btnCancel.Text = "A:Cancel";
			this.btnCancel.UseVisualStyleBackColor = true;
			this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
			this.lblEnterUserAndPassword.AutoSize = true;
			this.lblEnterUserAndPassword.Location = new Point(12, 9);
			this.lblEnterUserAndPassword.Name = "lblEnterUserAndPassword";
			this.lblEnterUserAndPassword.Size = new Size(153, 13);
			this.lblEnterUserAndPassword.TabIndex = 3;
			this.lblEnterUserAndPassword.Text = "A:Enter username and password:";
			base.AcceptButton = this.btnOk;
			base.AutoScaleDimensions = new SizeF(6f, 13f);
			base.AutoScaleMode = AutoScaleMode.Font;
			base.CancelButton = this.btnCancel;
			base.ClientSize = new Size(444, 295);
			base.Controls.Add(this.pnlFooterButtons);
			base.Controls.Add(this.grpDatabase);
			base.Controls.Add(this.grpProvider);
			base.Controls.Add(this.lblEnterUserAndPassword);
			base.MaximizeBox = false;
			this.MinimumSize = new Size(452, 329);
			base.Name = "RemoteCreditDialog";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterParent;
			this.Text = "A:Enter User Credentials";
			this.grpProvider.ResumeLayout(false);
			this.grpProvider.PerformLayout();
			this.grpDatabase.ResumeLayout(false);
			this.grpDatabase.PerformLayout();
			this.pnlFooterButtons.ResumeLayout(false);
			base.ResumeLayout(false);
			base.PerformLayout();
		}
	}
}
